<%@page import="backend.db.ORM" %>
<%@page import="backend.User" %>
<script type="text/javascript" src="public/types.js"></script>
<script type="text/javascript" src="shared/editUserAccount.js"></script>
<script type="text/javascript" src="public/register.js"></script>
<div id="main-editUserAccount" style="text-align:center;">
	<%
		String userName = request.getUserPrincipal().getName();
		User user = ORM.getUser(userName);
	%>
		<table style="width:50%;border-collapse:collapse;position:absolute;left:33%;top:50%;">
			<tr style="height:30%;">
				<td style="width:30%;"><h2><b>username: </b></h2></td>
				<td style="text-align:left;"><h2><%= user.username %></h2></td>
			</tr>
			<tr>
				<td><h2><b>role: </b></h2></td> 
				<td><h2><%= user.role %></h2></td>
			</tr>
			<tr>
				<td><h2><b>full name: </b></h2></td> 
				<td id="fullnameTD"><p class="par3"><%=user.name %></p></td>
			</tr>
			<tr>
				<td><h2><b>phone: </b></h2></td> 
				<td id="phoneTD">
				<%
				if(user.phone.equals(""))
				{
				%>
					<p class="par3">add?</p>
				<%
				}
				else
				{
				%>
					<p class="par3"><%= user.phone %></p>
				<%		
				}
				%>
				</td>
			</tr>
			<tr>
				<td><h2><b>address: </b></h2></td> 
				<td id="addressTD">		 	 
				<%
				if(user.address.equals(""))
				{
				%>
					<p class="par3">add?</p>
				<%
				}
				else
				{
				%>
					<p class="par3"><%= user.address %></p>
				<%		
				}
				%>
				</td>
			</tr>
			<tr>
				<td id="passTD" style="width:50%;"><p class="par3">change password?</p></td> 
				<td id="passStrength"></td>
				<td id="confirmText" class="errorText"></td>
			</tr>
		</table>
	<form id="editForm" action="#">
		<div>
		<input type="hidden" name="action" value="" />
		<input type="hidden" name="username" value="<%= user.username %>" />
		<input type="hidden" id="newValue" name="newValue" value="" />
		</div>
	</form>
	<script type="text/javascript">
		setPostFormToServletWithCompleteFunc('editForm', 'shared/editUserAccount', function(xhr) {if (xhr.status != 200) loadPage('shared/editUserAccount.jsp?reason=invalid');});
	</script>
	<div>
		<input type="hidden" id="hiddenPass" value="<%= user.password %>" />
	</div>
</div>
